/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cx1.service.utils.scheduled;

import java.util.Date;
import java.util.Timer;

/**
 *
 * @author ECH
 */
public class TSEmailServices {
    
    private Timer sendEmailInviteTimer = new Timer();
    private boolean sendEmailInviteServiceRunning = false;
    private Date sendEmailInviteServiceStartDate;
    private long sendEmailInviteServiceInterval;
    
    private TKSendEmailInvite taskSendEmailInvite = new TKSendEmailInvite();

    public void startSendEmailInviteService(Date startDate, long interval) {
        try {
            if (!sendEmailInviteServiceRunning) {
                this.sendEmailInviteTimer = new Timer();
                this.taskSendEmailInvite = new TKSendEmailInvite();            
                this.sendEmailInviteTimer.scheduleAtFixedRate(this.taskSendEmailInvite, startDate, interval);

                this.setSendEmailInviteServiceStartDate(startDate);
                this.setSendEmailInviteServiceInterval(interval);
                this.setSendEmailInviteServiceRunning(true);                
            }
        } 
        catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void stopSendEmailInviteService() {     
        try {   
            sendEmailInviteTimer.cancel();
            sendEmailInviteTimer.purge();
            this.setSendEmailInviteServiceRunning(false);
        } catch (Exception ex) {}
    }
    
    public Timer getSendEmailInviteTimer() {
        return sendEmailInviteTimer;
    }

    public void setSendEmailInviteTimer(Timer sendEmailInviteTimer) {
        this.sendEmailInviteTimer = sendEmailInviteTimer;
    }

    public Date getSendEmailInviteServiceStartDate() {
        return sendEmailInviteServiceStartDate;
    }

    public void setSendEmailInviteServiceStartDate(Date sendEmailInviteServiceStartDate) {
        this.sendEmailInviteServiceStartDate = sendEmailInviteServiceStartDate;
    }

    public boolean isSendEmailInviteServiceRunning() {
        return sendEmailInviteServiceRunning;
    }

    public void setSendEmailInviteServiceRunning(boolean sendEmailInviteServiceRunning) {
        this.sendEmailInviteServiceRunning = sendEmailInviteServiceRunning;
    }

    public long getSendEmailInviteServiceInterval() {
        return sendEmailInviteServiceInterval;
    }

    public void setSendEmailInviteServiceInterval(long sendEmailInviteServiceInterval) {
        this.sendEmailInviteServiceInterval = sendEmailInviteServiceInterval;
    }

    public TKSendEmailInvite getTaskSendEmailInvite() {
        return taskSendEmailInvite;
    }

    public void setTaskSendEmailInvite(TKSendEmailInvite taskSendEmailInvite) {
        this.taskSendEmailInvite = taskSendEmailInvite;
    }

    
}
